package fr.umlv.m2.jee.pmlv.persistence.subject.dao;

import java.util.List;
import org.springframework.stereotype.Repository;

import fr.umlv.m2.jee.pmlv.framework.dao.hibernate.AbstractHibernateDAO;
import fr.umlv.m2.jee.pmlv.persistence.subject.AbstractTheme;
import java.util.ArrayList;

/**
 * DAO for the class {@link AbstractTheme} with the framework Hibernate.
 * This class implements {@link IAbstractThemeDAO}.
 * @author jenseric
 *
 */
@Repository("hibernateAbstractThemeDAO")
public class HibernateAbstractThemeDAO extends AbstractHibernateDAO<Long, AbstractTheme> implements IAbstractThemeDAO {

    @Override
    public List<AbstractTheme> findBySubjectIdAndByYear(Long id, int year) {
        List<AbstractTheme>  list = new ArrayList<AbstractTheme>();
        String query = "select distinct theme from AbstractTheme as theme "
                + " where theme.year="+year+" and theme.subject.id="+id;
        list.addAll(findByQuery(query));
        return list;
    }
}



